// import test from "../test";


Component({
  pageLifetimes: {
    show() {
      
      this.test()
      

    },
  
  },


  data: {
    buttons: [
      { id: 1, name: '当日',checked:true }, 
      { id: 2, name: '当月',checked:false }, 
      { id: 3, name: '当年',checked:false }
    ],
    tableHeader: [
      {
        prop: 'salename',
        width: 110,
        label: '销售单位',
        // color: 'red'
      },
      {
        prop: 'accept',
        width: 90,
        label: '接单额'
      },
      {
        prop: 'ship',
        width: 90,
        label: '出货额'
      },
      {
        prop: 'back',
        width: 90,
        label: '回款额'
      },
      {
        prop: 'delay',
        width: 95,
        label: '应收未收'
      },
      {
        prop: 'marginRate',
        width: 90,
        label: '毛利率'
      },
      {
        prop: 'okRate',
        width: 90,
        label: '准交率'
      },
      {
        prop: 'complaintRate',
        width: 90,
        label: '投诉率'
      }
    ],
    stripe: true,
    border: true,
    outBorder: true,
    row: [
      {
          "salename": '业务一部',
          "accept": "16",
          "ship": '20',
          "back": '18',
          "delay": 8,
          "marginRate": 15,
          "okRate": 90,
          "complaintRate": 2
      }
    ],

  },
  

  methods: {

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function () {
      this.data.buttons[5].checked=true;
      this.setData({
        buttons: this.data.buttons,
      })
    },
    radioButtonTap: function (e) {
      console.log(e)
      let id = e.currentTarget.dataset.id
      console.log(id)
      for (let i = 0; i < this.data.row.length; i++) {
        this.data.row[i].status=id
      }
      for (let i = 0; i < this.data.buttons.length; i++) {
        if (this.data.buttons[i].id == id) {
          //当前点击的位置为true即选中
          this.data.buttons[i].checked = true;
        }
        else {
          //其他的位置为false
          this.data.buttons[i].checked = false;
        }
      }
      this.setData({
        buttons: this.data.buttons,
        row:this.data.row
      })
      // this.setData({
      //   row:this.data.row,
        
      // })
      
    },

    //搜索框
    search(e) {
      const { value } = e.detail;
      const list = [
        'tdesign-vue',
        'tdesign-react',
        'tdesign-miniprogram',
        'tdesign-angular',
        'tdesign-mobile-vue',
        'tdesign-mobile-react',
      ];
      this.setData({
        resultList: value ? list.filter((v) => v.includes(value)) : [],
      });
    },

    
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady:function() {
    },

    test(){
      wx.request({
        url:'http://10.10.50.30:8090/test',

        header: {
          'content-type': 'application/json' // 默认值
        },
        success :(res) =>{
          this.setData({
            test: res.data,
          })
        }
      })
    },
      
    
    /**
     * 生命周期函数--监听页面显示
     */
    onShow:function() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide:function() {
      
    },
 
  },

    
})


